package 责任链;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

@Data
public class DutyLinkConfig {

    private List<MyFunction> dutyList = new ArrayList<>();

    private Stu stu;



    public DutyLinkConfig add(MyFunction function){
        this.dutyList.add(function);
        return this;
    }

    public boolean execute(){

        for (MyFunction myFunction : dutyList) {
            if (!myFunction.apply(this.stu)) {
                throw new RuntimeException("function check error");
            }
        }
        return true;
    }



}
